//
//  YTNavViewController.m
//  yitaicaijing
//
//  Created by DIANGHONG on 2018/7/9.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "YTNavViewController.h"

@interface YTNavViewController ()<UINavigationControllerDelegate>

@property (strong, nonatomic)  UIPanGestureRecognizer *pan;

@end

@implementation YTNavViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:15]}];
    //[self.navigationBar setBackgroundColor:UIColor.whiteColor];
    //设置右滑返回手势的代理为自身
    __weak typeof(self) weakself = self;
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.interactivePopGestureRecognizer.delegate = (id)weakself;
    }
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // 如果不是根控制器 隐藏tabbar
    if (self.childViewControllers.count > 0) {viewController.hidesBottomBarWhenPushed = true;
        
    }
    
    
    [super pushViewController:viewController animated:true];
    
//    if ([viewController isMemberOfClass:[DHHomeController class]])
//    {viewController.navigationController.navigationBar.hidden = true;}
    
    
    
}
#pragma mark - UIGestureRecognizerDelegate
//这个方法是在手势将要激活前调用：返回YES允许右滑手势的激活，返回NO不允许右滑手势的激活
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if (gestureRecognizer == self.interactivePopGestureRecognizer) {
        //屏蔽调用rootViewController的滑动返回手势，避免右滑返回手势引起死机问题
        if (self.viewControllers.count < 2 ||
            self.visibleViewController == [self.viewControllers objectAtIndex:0]) {
            return NO;
        }
    }
    //这里就是非右滑手势调用的方法啦，统一允许激活
    return YES;
}




@end
